package com.iknow.http;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Build.VERSION;
import com.iknow.IKnow;
import com.iknow.IKnowApiV4;
import com.iknow.util.Loger;
import com.iknow.util.SystemUtil;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLHandshakeException;
import org.apache.http.Header;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.NoHttpResponseException;
import org.apache.http.ProtocolException;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.AuthState;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CookieStore;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.RedirectHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.json.JSONException;
import org.json.JSONObject;

public class HttpClient
{
  public static final int BAD_GATEWAY = 502;
  public static final int BAD_REQUEST = 400;
  private static final int CONNECTION_TIMEOUT_MS = 30000;
  private static final boolean DEBUG = 1;
  public static final int FORBIDDEN = 403;
  public static final int INTERNAL_SERVER_ERROR = 500;
  public static final int NOT_ACCEPTABLE = 406;
  public static final int NOT_AUTHORIZED = 401;
  public static final int NOT_FOUND = 404;
  public static final int NOT_MODIFIED = 304;
  public static final int OK = 200;
  public static final int RETRIED_TIME = 3;
  public static final int RETRIEVE_LIMIT = 20;
  private static final String SERVER_HOST = "api.fanfou.com";
  public static final int SERVICE_UNAVAILABLE = 503;
  private static final int SOCKET_TIMEOUT_MS = 30000;
  private static final String TAG = "HttpClient";
  private static boolean isAuthenticationEnabled = false;
  private static HttpRequestRetryHandler requestRetryHandler = new HttpRequestRetryHandler()
  {
    public boolean retryRequest(, int paramInt, HttpContext paramHttpContext)
    {
      int i;
      if (paramInt >= 3)
        i = 0;
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              return i;
              if (!(paramIOException instanceof NoHttpResponseException))
                break;
              i = 1;
            }
            if (!(paramIOException instanceof SSLHandshakeException))
              break;
            i = 0;
          }
          if (((HttpRequest)paramHttpContext.getAttribute("http.request")) instanceof HttpEntityEnclosingRequest)
            break;
          i = 1;
        }
        i = 0;
      }
    }
  };
  private String Mozilla = null;
  private BasicHttpContext localcontext;
  private AuthScope mAuthScope;
  private DefaultHttpClient mClient;
  private CookieStore mCookieStore;
  private String mPassword;
  private String mUserId;
  private HttpRequestInterceptor preemptiveAuth;

  public HttpClient()
  {
    this.preemptiveAuth = new HttpRequestInterceptor(this)
    {
      public void process(, HttpContext paramHttpContext)
      {
        AuthState localAuthState = (AuthState)paramHttpContext.getAttribute("http.auth.target-scope");
        CredentialsProvider localCredentialsProvider = (CredentialsProvider)paramHttpContext.getAttribute("http.auth.credentials-provider");
        HttpHost localHttpHost = (HttpHost)paramHttpContext.getAttribute("http.target_host");
        if (localAuthState.getAuthScheme() == null)
        {
          Credentials localCredentials = localCredentialsProvider.getCredentials(new AuthScope(localHttpHost.getHostName(), localHttpHost.getPort()));
          if (localCredentials != null)
          {
            localAuthState.setAuthScheme(new BasicScheme());
            localAuthState.setCredentials(localCredentials);
          }
        }
      }
    };
    initMozilla();
    prepareHttpClient();
  }

  public HttpClient(String paramString1, String paramString2)
  {
    this.preemptiveAuth = new HttpRequestInterceptor(this)
    {
      public void process(, HttpContext paramHttpContext)
      {
        AuthState localAuthState = (AuthState)paramHttpContext.getAttribute("http.auth.target-scope");
        CredentialsProvider localCredentialsProvider = (CredentialsProvider)paramHttpContext.getAttribute("http.auth.credentials-provider");
        HttpHost localHttpHost = (HttpHost)paramHttpContext.getAttribute("http.target_host");
        if (localAuthState.getAuthScheme() == null)
        {
          Credentials localCredentials = localCredentialsProvider.getCredentials(new AuthScope(localHttpHost.getHostName(), localHttpHost.getPort()));
          if (localCredentials != null)
          {
            localAuthState.setAuthScheme(new BasicScheme());
            localAuthState.setCredentials(localCredentials);
          }
        }
      }
    };
    prepareHttpClient();
    setCredentials(paramString1, paramString2);
  }

  private void HandleResponseStatusCode(int paramInt, Response paramResponse)
    throws HttpException
  {
    String str = getCause(paramInt) + "\n";
    switch (paramInt)
    {
    default:
      throw new HttpException(str + paramResponse.asString(), paramInt);
    case 304:
    case 400:
    case 404:
    case 406:
      JSONObject localJSONObject = paramResponse.asJSONObject();
      try
      {
        throw new HttpException(str + localJSONObject.getString("msg"), paramInt);
      }
      catch (JSONException localJSONException)
      {
        throw new HttpException(str + "unknow error!", paramInt);
      }
    case 401:
      throw new HttpAuthException(str + paramResponse.asString(), paramInt);
    case 403:
      throw new HttpRefusedException(str, paramInt);
    case 500:
    case 502:
    case 503:
      throw new HttpServerException(str, paramInt);
    case 200:
    }
  }

  private void SetupHTTPConnectionParams(HttpUriRequest paramHttpUriRequest)
  {
    HttpConnectionParams.setConnectionTimeout(paramHttpUriRequest.getParams(), 30000);
    HttpConnectionParams.setSoTimeout(paramHttpUriRequest.getParams(), 30000);
    HttpClientParams.setRedirecting(paramHttpUriRequest.getParams(), true);
    this.mClient.setHttpRequestRetryHandler(requestRetryHandler);
    paramHttpUriRequest.addHeader("Accept-Encoding", "gzip, deflate");
    paramHttpUriRequest.addHeader("User-Agent", this.Mozilla);
    this.mClient.setRedirectHandler(new RedirectHandler(this)
    {
      public URI getLocationURI(, HttpContext paramHttpContext)
        throws ProtocolException
      {
        URI localURI;
        String str;
        int i = paramHttpResponse.getStatusLine().getStatusCode();
        if ((i == 301) || (i == 302) || (i == 303) || (i == 307))
        {
          Header[] arrayOfHeader = paramHttpResponse.getHeaders("Location");
          if ((arrayOfHeader != null) && (arrayOfHeader.length != 0))
            str = arrayOfHeader[(arrayOfHeader.length - 1)].getValue();
        }
        try
        {
          if (str.indexOf("c/..\\") != -1)
            str = str.replace("c/..\\", "").replace("\\", "/");
          localURI = new URI(str);
          return localURI;
        }
        catch (URISyntaxException localURISyntaxException)
        {
          localURISyntaxException.printStackTrace();
          localURI = null;
        }
      }

      public boolean isRedirectRequested(, HttpContext paramHttpContext)
      {
        int j;
        int i = paramHttpResponse.getStatusLine().getStatusCode();
        if ((i == 301) || (i == 302) || (i == 303) || (i == 307))
          j = 1;
        while (true)
        {
          return j;
          j = 0;
        }
      }
    });
  }

  // ERROR //
  private HttpUriRequest createMethod(String paramString, URI paramURI, File paramFile, ArrayList<BasicNameValuePair> paramArrayList)
    throws HttpException
  {
    // Byte code:
    //   0: aload_1
    //   1: ldc 204
    //   3: invokevirtual 208	java/lang/String:equalsIgnoreCase	(Ljava/lang/String;)Z
    //   6: ifeq +97 -> 103
    //   9: new 210	org/apache/http/client/methods/HttpPost
    //   12: dup
    //   13: aload_2
    //   14: invokespecial 213	org/apache/http/client/methods/HttpPost:<init>	(Ljava/net/URI;)V
    //   17: astore 5
    //   19: aload 5
    //   21: invokevirtual 214	org/apache/http/client/methods/HttpPost:getParams	()Lorg/apache/http/params/HttpParams;
    //   24: ldc 216
    //   26: iconst_0
    //   27: invokeinterface 222 3 0
    //   32: pop
    //   33: aload_3
    //   34: ifnull +20 -> 54
    //   37: aload 5
    //   39: aload_0
    //   40: ldc 224
    //   42: aload_3
    //   43: aload 4
    //   45: invokespecial 228	com/iknow/http/HttpClient:createMultipartEntity	(Ljava/lang/String;Ljava/io/File;Ljava/util/ArrayList;)Lorg/apache/http/entity/mime/MultipartEntity;
    //   48: invokevirtual 232	org/apache/http/client/methods/HttpPost:setEntity	(Lorg/apache/http/HttpEntity;)V
    //   51: goto +96 -> 147
    //   54: aload 4
    //   56: ifnull +91 -> 147
    //   59: new 234	org/apache/http/client/entity/UrlEncodedFormEntity
    //   62: dup
    //   63: aload 4
    //   65: ldc 236
    //   67: invokespecial 239	org/apache/http/client/entity/UrlEncodedFormEntity:<init>	(Ljava/util/List;Ljava/lang/String;)V
    //   70: astore 7
    //   72: aload 5
    //   74: aload 7
    //   76: invokevirtual 232	org/apache/http/client/methods/HttpPost:setEntity	(Lorg/apache/http/HttpEntity;)V
    //   79: goto +68 -> 147
    //   82: astore 11
    //   84: aload 11
    //   86: astore 9
    //   88: new 95	HttpException
    //   91: dup
    //   92: aload 9
    //   94: invokevirtual 242	java/io/IOException:getMessage	()Ljava/lang/String;
    //   97: aload 9
    //   99: invokespecial 245	HttpException:<init>	(Ljava/lang/String;Ljava/lang/Exception;)V
    //   102: athrow
    //   103: aload_1
    //   104: ldc 247
    //   106: invokevirtual 208	java/lang/String:equalsIgnoreCase	(Ljava/lang/String;)Z
    //   109: ifeq +16 -> 125
    //   112: new 249	org/apache/http/client/methods/HttpDelete
    //   115: dup
    //   116: aload_2
    //   117: invokespecial 250	org/apache/http/client/methods/HttpDelete:<init>	(Ljava/net/URI;)V
    //   120: astore 10
    //   122: goto +29 -> 151
    //   125: new 252	org/apache/http/client/methods/HttpGet
    //   128: dup
    //   129: aload_2
    //   130: invokespecial 253	org/apache/http/client/methods/HttpGet:<init>	(Ljava/net/URI;)V
    //   133: astore 10
    //   135: goto +16 -> 151
    //   138: astore 8
    //   140: aload 8
    //   142: astore 9
    //   144: goto -56 -> 88
    //   147: aload 5
    //   149: astore 10
    //   151: aload 10
    //   153: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   37	72	82	java/io/IOException
    //   72	79	138	java/io/IOException
  }

  private MultipartEntity createMultipartEntity(String paramString, File paramFile, ArrayList<BasicNameValuePair> paramArrayList)
    throws UnsupportedEncodingException
  {
    MultipartEntity localMultipartEntity = new MultipartEntity();
    localMultipartEntity.addPart(paramString, new FileBody(paramFile));
    Iterator localIterator = paramArrayList.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
        return localMultipartEntity;
      BasicNameValuePair localBasicNameValuePair = (BasicNameValuePair)localIterator.next();
      localMultipartEntity.addPart(localBasicNameValuePair.getName(), new StringBody(localBasicNameValuePair.getValue()));
    }
  }

  private URI createURI(String paramString)
    throws HttpException
  {
    URI localURI;
    try
    {
      localURI = new URI(paramString);
      return localURI;
    }
    catch (URISyntaxException localURISyntaxException)
    {
      Loger.e("HttpClient", localURISyntaxException.getMessage(), localURISyntaxException);
      throw new HttpException("Invalid URL.");
    }
  }

  private void enableDebug()
  {
    Loger.i("HttpClient", "enable apache.http debug");
    Logger.getLogger("org.apache.http").setLevel(Level.FINEST);
    Logger.getLogger("org.apache.http.wire").setLevel(Level.FINER);
    Logger.getLogger("org.apache.http.headers").setLevel(Level.OFF);
  }

  public static String encode(String paramString)
    throws HttpException
  {
    String str;
    try
    {
      str = URLEncoder.encode(paramString, "UTF-8");
      return str;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      throw new HttpException(localUnsupportedEncodingException.getMessage(), localUnsupportedEncodingException);
    }
  }

  public static String encodeParameters(ArrayList<BasicNameValuePair> paramArrayList)
    throws HttpException
  {
    StringBuffer localStringBuffer = new StringBuffer();
    int i = 0;
    if (i >= paramArrayList.size())
      return localStringBuffer.toString();
    if (i != 0)
      localStringBuffer.append("&");
    try
    {
      localStringBuffer.append(URLEncoder.encode(((BasicNameValuePair)paramArrayList.get(i)).getName(), "UTF-8")).append("=").append(URLEncoder.encode(((BasicNameValuePair)paramArrayList.get(i)).getValue(), "UTF-8"));
      ++i;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      throw new HttpException(localUnsupportedEncodingException.getMessage(), localUnsupportedEncodingException);
    }
  }

  private static String getCause(int paramInt)
  {
    String str = null;
    switch (paramInt)
    {
    default:
      str = "";
    case 304:
    case 400:
    case 401:
    case 403:
    case 404:
    case 406:
    case 500:
    case 502:
    case 503:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    return paramInt + ":" + str;
                    str = "The request was invalid.  An accompanying error message will explain why. This is the status code will be returned during rate limiting.";
                  }
                  str = "Authentication credentials were missing or incorrect.";
                }
                str = "The request is understood, but it has been refused.  An accompanying error message will explain why.";
              }
              str = "The URI requested is invalid or the resource requested, such as a user, does not exists.";
            }
            str = "Returned by the Search API when an invalid format is specified in the request.";
          }
          str = "Something is broken.  Please post to the group so the Weibo team can investigate.";
        }
        str = "Weibo is down or being upgraded.";
      }
      str = "Service Unavailable: The Weibo servers are up, but overloaded with requests. Try again later. The search and trend methods use this to indicate when you are being rate limited.";
    }
  }

  public static void log(String paramString)
  {
    Loger.d("HttpClient", paramString);
  }

  private void prepareHttpClient()
  {
    enableDebug();
    BasicHttpParams localBasicHttpParams = new BasicHttpParams();
    ConnManagerParams.setMaxTotalConnections(localBasicHttpParams, 10);
    HttpProtocolParams.setVersion(localBasicHttpParams, HttpVersion.HTTP_1_1);
    SchemeRegistry localSchemeRegistry = new SchemeRegistry();
    localSchemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    localSchemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    this.mClient = new DefaultHttpClient(new ThreadSafeClientConnManager(localBasicHttpParams, localSchemeRegistry), localBasicHttpParams);
    BasicScheme localBasicScheme = new BasicScheme();
    this.mAuthScope = new AuthScope("api.fanfou.com", -1);
    this.mClient.setCredentialsProvider(new BasicCredentialsProvider());
    this.localcontext = new BasicHttpContext();
    this.localcontext.setAttribute("preemptive-auth", localBasicScheme);
    this.mClient.addRequestInterceptor(this.preemptiveAuth, 0);
  }

  /**
   * @deprecated
   */
  private void setCookie()
  {
    monitorenter;
    try
    {
      CookieStore localCookieStore = this.mCookieStore;
      if (localCookieStore == null)
      {
        monitorexit;
        return;
      }
      BasicClientCookie localBasicClientCookie = new BasicClientCookie("JSESSIONID", IKnow.mApi.getSession());
      localBasicClientCookie.setVersion(0);
      localBasicClientCookie.setDomain("www.imiknow.com");
      localBasicClientCookie.setPath("/iks");
      this.mCookieStore.clear();
      this.mCookieStore.addCookie(localBasicClientCookie);
      this.mClient.setCookieStore(this.mCookieStore);
    }
    finally
    {
      monitorexit;
    }
  }

  public Response get(String paramString)
    throws HttpException
  {
    return httpRequest(paramString, null, false, "GET");
  }

  public Response get(String paramString, ArrayList<BasicNameValuePair> paramArrayList)
    throws HttpException
  {
    return httpRequest(paramString, paramArrayList, false, "GET");
  }

  public Response get(String paramString, ArrayList<BasicNameValuePair> paramArrayList, boolean paramBoolean)
    throws HttpException
  {
    return httpRequest(paramString, paramArrayList, paramBoolean, "GET");
  }

  public Response get(String paramString, boolean paramBoolean)
    throws HttpException
  {
    return httpRequest(paramString, null, paramBoolean, "GET");
  }

  public String getPassword()
  {
    return this.mPassword;
  }

  public String getUserId()
  {
    return this.mUserId;
  }

  // ERROR //
  public Response httpRequest(String paramString1, ArrayList<BasicNameValuePair> paramArrayList, File paramFile, boolean paramBoolean, String paramString2)
    throws HttpException
  {
    // Byte code:
    //   0: ldc 48
    //   2: new 99	java/lang/StringBuilder
    //   5: dup
    //   6: ldc_w 557
    //   9: invokespecial 112	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   12: aload 5
    //   14: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   17: ldc_w 559
    //   20: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   23: aload_1
    //   24: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   27: invokevirtual 122	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   30: invokestatic 317	com/iknow/util/Loger:i	(Ljava/lang/String;Ljava/lang/String;)V
    //   33: invokestatic 565	java/lang/System:currentTimeMillis	()J
    //   36: lstore 6
    //   38: aload_1
    //   39: astore 8
    //   41: aload_2
    //   42: ifnull +58 -> 100
    //   45: new 99	java/lang/StringBuilder
    //   48: dup
    //   49: invokespecial 566	java/lang/StringBuilder:<init>	()V
    //   52: astore 9
    //   54: aload_2
    //   55: invokevirtual 273	java/util/ArrayList:iterator	()Ljava/util/Iterator;
    //   58: astore 10
    //   60: aload 10
    //   62: invokeinterface 279 1 0
    //   67: ifne +159 -> 226
    //   70: new 99	java/lang/StringBuilder
    //   73: dup
    //   74: aload_1
    //   75: invokestatic 109	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   78: invokespecial 112	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   81: ldc_w 568
    //   84: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   87: aload 9
    //   89: invokevirtual 122	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   92: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   95: invokevirtual 122	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   98: astore 8
    //   100: aload_0
    //   101: aload 5
    //   103: aload_0
    //   104: aload_1
    //   105: invokespecial 570	com/iknow/http/HttpClient:createURI	(Ljava/lang/String;)Ljava/net/URI;
    //   108: aload_3
    //   109: aload_2
    //   110: invokespecial 572	com/iknow/http/HttpClient:createMethod	(Ljava/lang/String;Ljava/net/URI;Ljava/io/File;Ljava/util/ArrayList;)Lorg/apache/http/client/methods/HttpUriRequest;
    //   113: astore 15
    //   115: aload_0
    //   116: aload 15
    //   118: invokespecial 574	com/iknow/http/HttpClient:SetupHTTPConnectionParams	(Lorg/apache/http/client/methods/HttpUriRequest;)V
    //   121: iload 4
    //   123: ifeq +7 -> 130
    //   126: aload_0
    //   127: invokespecial 576	com/iknow/http/HttpClient:setCookie	()V
    //   130: aload_0
    //   131: getfield 178	com/iknow/http/HttpClient:mClient	Lorg/apache/http/impl/client/DefaultHttpClient;
    //   134: aload 15
    //   136: aload_0
    //   137: getfield 476	com/iknow/http/HttpClient:localcontext	Lorg/apache/http/protocol/BasicHttpContext;
    //   140: invokevirtual 580	org/apache/http/impl/client/DefaultHttpClient:execute	(Lorg/apache/http/client/methods/HttpUriRequest;Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/HttpResponse;
    //   143: astore 25
    //   145: new 124	com/iknow/http/Response
    //   148: dup
    //   149: aload 25
    //   151: aload 8
    //   153: invokespecial 583	com/iknow/http/Response:<init>	(Lorg/apache/http/HttpResponse;Ljava/lang/String;)V
    //   156: astore 26
    //   158: aload_0
    //   159: aload_0
    //   160: getfield 178	com/iknow/http/HttpClient:mClient	Lorg/apache/http/impl/client/DefaultHttpClient;
    //   163: invokevirtual 587	org/apache/http/impl/client/DefaultHttpClient:getCookieStore	()Lorg/apache/http/client/CookieStore;
    //   166: putfield 489	com/iknow/http/HttpClient:mCookieStore	Lorg/apache/http/client/CookieStore;
    //   169: aload 25
    //   171: ifnull +200 -> 371
    //   174: aload_0
    //   175: aload 25
    //   177: invokeinterface 593 1 0
    //   182: invokeinterface 598 1 0
    //   187: aload 26
    //   189: invokespecial 600	com/iknow/http/HttpClient:HandleResponseStatusCode	(ILcom/iknow/http/Response;)V
    //   192: invokestatic 565	java/lang/System:currentTimeMillis	()J
    //   195: lstore 30
    //   197: ldc 48
    //   199: new 99	java/lang/StringBuilder
    //   202: dup
    //   203: ldc_w 602
    //   206: invokespecial 112	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   209: lload 30
    //   211: lload 6
    //   213: lsub
    //   214: invokevirtual 605	java/lang/StringBuilder:append	(J)Ljava/lang/StringBuilder;
    //   217: invokevirtual 122	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   220: invokestatic 399	com/iknow/util/Loger:d	(Ljava/lang/String;Ljava/lang/String;)V
    //   223: aload 26
    //   225: areturn
    //   226: aload 10
    //   228: invokeinterface 283 1 0
    //   233: checkcast 285	org/apache/http/message/BasicNameValuePair
    //   236: astore 11
    //   238: aload 9
    //   240: aload 11
    //   242: invokevirtual 288	org/apache/http/message/BasicNameValuePair:getName	()Ljava/lang/String;
    //   245: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   248: pop
    //   249: aload 9
    //   251: ldc_w 373
    //   254: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   257: pop
    //   258: aload 9
    //   260: aload 11
    //   262: invokevirtual 293	org/apache/http/message/BasicNameValuePair:getValue	()Ljava/lang/String;
    //   265: invokevirtual 118	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   268: pop
    //   269: goto -209 -> 60
    //   272: astore 22
    //   274: aload 22
    //   276: astore 23
    //   278: ldc 48
    //   280: aload 23
    //   282: invokevirtual 606	org/apache/http/client/ClientProtocolException:getMessage	()Ljava/lang/String;
    //   285: aload 23
    //   287: invokestatic 308	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   290: new 95	HttpException
    //   293: dup
    //   294: aload 23
    //   296: invokevirtual 606	org/apache/http/client/ClientProtocolException:getMessage	()Ljava/lang/String;
    //   299: aload 23
    //   301: invokespecial 245	HttpException:<init>	(Ljava/lang/String;Ljava/lang/Exception;)V
    //   304: astore 24
    //   306: aload 24
    //   308: athrow
    //   309: astore 19
    //   311: aload 19
    //   313: astore 20
    //   315: new 95	HttpException
    //   318: dup
    //   319: aload 20
    //   321: invokevirtual 242	java/io/IOException:getMessage	()Ljava/lang/String;
    //   324: aload 20
    //   326: invokespecial 245	HttpException:<init>	(Ljava/lang/String;Ljava/lang/Exception;)V
    //   329: astore 21
    //   331: aload 21
    //   333: athrow
    //   334: astore 16
    //   336: aload 16
    //   338: astore 17
    //   340: ldc 48
    //   342: aload 17
    //   344: invokevirtual 607	java/lang/IllegalStateException:getMessage	()Ljava/lang/String;
    //   347: aload 17
    //   349: invokestatic 308	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   352: new 95	HttpException
    //   355: dup
    //   356: aload 17
    //   358: invokevirtual 607	java/lang/IllegalStateException:getMessage	()Ljava/lang/String;
    //   361: aload 17
    //   363: invokespecial 245	HttpException:<init>	(Ljava/lang/String;Ljava/lang/Exception;)V
    //   366: astore 18
    //   368: aload 18
    //   370: athrow
    //   371: ldc 48
    //   373: ldc_w 609
    //   376: invokestatic 611	com/iknow/util/Loger:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   379: goto -187 -> 192
    //   382: astore 29
    //   384: aload 29
    //   386: astore 17
    //   388: goto -48 -> 340
    //   391: astore 28
    //   393: aload 28
    //   395: astore 20
    //   397: goto -82 -> 315
    //   400: astore 27
    //   402: aload 27
    //   404: astore 23
    //   406: goto -128 -> 278
    //
    // Exception table:
    //   from	to	target	type
    //   126	158	272	org/apache/http/client/ClientProtocolException
    //   126	158	309	java/io/IOException
    //   126	158	334	java/lang/IllegalStateException
    //   158	169	382	java/lang/IllegalStateException
    //   158	169	391	java/io/IOException
    //   158	169	400	org/apache/http/client/ClientProtocolException
  }

  public Response httpRequest(String paramString1, ArrayList<BasicNameValuePair> paramArrayList, boolean paramBoolean, String paramString2)
    throws HttpException
  {
    return httpRequest(paramString1, paramArrayList, null, paramBoolean, paramString2);
  }

  public void initMozilla()
  {
    String str1 = Build.MODEL;
    String str2 = Build.VERSION.RELEASE.substring(0, 3);
    String str3 = SystemUtil.getIMEI();
    int i = SystemUtil.getDisplayHeight();
    int j = SystemUtil.getDisplayWidth();
    String str4 = String.valueOf(i) + "*" + String.valueOf(j);
    PackageManager localPackageManager = IKnow.mContext.getPackageManager();
    Object localObject = null;
    try
    {
      PackageInfo localPackageInfo = localPackageManager.getPackageInfo(IKnow.mContext.getPackageName(), 16384);
      localObject = localPackageInfo;
      String str5 = String.valueOf(localObject.versionCode);
      String str6 = localObject.versionName;
      Loger.i("HttpClient", str6);
      this.Mozilla = "Mozilla/5.5 (" + str1 + ";" + "Android " + str2 + ";" + str3 + ";" + str4 + ";" + "zh-cn" + ")" + " iknow_android" + "/" + str5 + " ver/" + str6;
      Loger.i("HttpClient", this.Mozilla);
      return;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      localNameNotFoundException.printStackTrace();
    }
  }

  public boolean isAuthenticationEnabled()
  {
    return isAuthenticationEnabled;
  }

  public Response post(String paramString)
    throws HttpException
  {
    return httpRequest(paramString, null, false, "POST");
  }

  public Response post(String paramString, File paramFile)
    throws HttpException
  {
    return httpRequest(paramString, null, paramFile, false, "POST");
  }

  public Response post(String paramString, File paramFile, boolean paramBoolean)
    throws HttpException
  {
    return httpRequest(paramString, null, paramFile, paramBoolean, "POST");
  }

  public Response post(String paramString, ArrayList<BasicNameValuePair> paramArrayList)
    throws HttpException
  {
    return httpRequest(paramString, paramArrayList, false, "POST");
  }

  public Response post(String paramString, ArrayList<BasicNameValuePair> paramArrayList, boolean paramBoolean)
    throws HttpException
  {
    if (paramArrayList == null)
      paramArrayList = new ArrayList();
    return httpRequest(paramString, paramArrayList, paramBoolean, "POST");
  }

  public Response post(String paramString, boolean paramBoolean)
    throws HttpException
  {
    return httpRequest(paramString, null, paramBoolean, "POST");
  }

  public void removeProxy()
  {
    this.mClient.getParams().removeParameter("http.route.default-proxy");
  }

  public void reset()
  {
    setCredentials("", "");
  }

  public void setCredentials(String paramString1, String paramString2)
  {
    this.mUserId = paramString1;
    this.mPassword = paramString2;
    this.mClient.getCredentialsProvider().setCredentials(this.mAuthScope, new UsernamePasswordCredentials(paramString1, paramString2));
    isAuthenticationEnabled = true;
  }

  public void setProxy(String paramString1, int paramInt, String paramString2)
  {
    HttpHost localHttpHost = new HttpHost(paramString1, paramInt, paramString2);
    this.mClient.getParams().setParameter("http.route.default-proxy", localHttpHost);
  }
}